<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class NewsListResource extends JsonResource
{
	public function toArray($request)
	{
		$resource = $this->resource;
		
		return [
			'id'                => (int)$resource->id,
			'images'             =>  $resource->bf_url ? img_path($resource->bf_url) : '',
			'title_cn'              =>$resource->title_cn ?? '',
			'title_zn'              =>$resource->title_zn ? explode("#",$resource->title_zn)[0] :  '',
			'brief_zn'              =>$resource->brief_zn ?? '',
			'url' =>$resource->url ?? '',
			'source' =>$resource->source ?? '',
			'created_at' => (string)$resource->created_at ?? '',
			'started_at' => (string)$resource->started_at ?? '',
			
		];
	}
}
